package jflowmap.model.ontology;

import java.util.List;

public enum Aggregators implements Aggregator {

	SUM {
		@Override
		public Value aggregate(final List<Value> values, final Context context) {
			double sum = values.size() == 0 ? Double.NaN : 0;
			
			for (Value v: values) {
				sum += v.getValue();
			}
			
			if (values.size() == 0) return Context.missingValue;
			else return context.create(sum).in(values.get(0).getMeasurement());
		}
	}
}
